package com.rockwell.robot2015.model.sensors;

public interface IRobotSensors {
	
	public static final int LEFT_DISTANCE_SENSOR_REF = 1;
	public static final int RIGHT_DISTANCE_SENSOR_REF = 2;
	public static final int SENSORS_STATUS_REF = 3;
	public static final int ANGLE_SENSORS_REF = 4;
	public static final int LEFT_TARGET_VALUE_REF = 5;
	public static final int LEFT_PRESENT_VALUE_REF = 6;
	public static final int RIGHT_TARGET_VALUE_REF = 7;
	public static final int RIGHT_PRESENT_VALUE_REF = 8;
	public static final int IN_MAZE_REF = 9;
	
	public static final int SENSOR_COUNT = 8;
	
	public static final short FRONT_SENSOR_MASK = 0x1;
	public static final short LEFT_SENSOR_MASK = 0x1 << 1;
	public static final short RIGHT_SENSOR_MASK = 0x1 << 2;
	public static final short ARM_DOWN_SENSOR_MASK = 0x1 << 3;
	public static final short ARM_UP_SENSOR_MASK = 0x1 << 4;
	public static final short RIGHT_TOO_CLOSE_MASK = 0x1 << 5;
	public static final short LEFT_FRONT_TOO_CLOSE_MASK = 0x1 << 6;
	public static final short LEFT_BACK_TOO_CLOSE_MASK = 0x1 << 7;
	public static final short FRONT_TOO_CLOSE_MASK = 0x1 << 8;
	
	public static final short IN_MAZE_MASK = 0x1;
	
	public static final int LEFT_ANGLE_DIRECTION = 0x1 << 15;
	public static final int LEFT_FRONT_SENSOR_MASK = 0x1 << 14;
	public static final int LEFT_BACK_SENSOR_MASK = 0x1 << 13;
	public static final int LEFT_ANGLE_SENSOR_MASK = 0x1fff;
	
	public static class LeftAngle {
		public boolean leftFrontOpen;
		public boolean leftBackOpen;
		public boolean direction;
		public int angle;
	}
	
	/**
	 * Detects if the robot has a distance sensor at the left side.
	 * @return
	 */
	boolean hasLeftDistanceSensor();
	
	/**
	 * Detects if the robot has a distance sensor at the front side.
	 * @return
	 */
	boolean hasFrontDistanceSensor();
	
	/**
	 * Detects if the robot has a distance sensor at the right side.
	 * @return
	 */
	boolean hasRightDistanceSensor();
	
	double getLeftDistance();
	double getRightDistance();
	boolean getFrontStatus();
	
	boolean detectLeftWall();
	boolean detectRightWall();
	
	boolean detectFrontWall();
	int[] getAllSensorStatus();
	
	/**
	 * Get the orientation of the vehicle.
	 * @return the orientation in degree
	 */
	float getOrientation();
	void setOrientation(float angle);

	boolean isArmUp();
	boolean isArmDown();
	
	LeftAngle getLeftAngle();
	
	boolean isRightTooClose();
	boolean isLeftFrontTooClose();
	boolean isLeftBackTooClose();
	boolean isFrontTooClose();
	
	/**
	 * Get the target value of the left motor
	 * @return
	 */
	int getLeftTargetValue();
	
	/**
	 * Get the present value of the left motor
	 * @return
	 */
	int getLeftPresentValue();
	
	int getRightTargetValue();
	int getRightPresentValue();
	
	void setInMaze(boolean in);
}
